/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import DTO.LOAISANPHAMDTO;
import UNTIL.DataProvider;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

/**
 *
 * @author NGUYEN
 */
public class LOAISANPHAMDAO {
    public ArrayList<LOAISANPHAMDTO> laydanhsachloaisanpham()
    {
        ArrayList<LOAISANPHAMDTO> ds = new ArrayList<LOAISANPHAMDTO>();
        DataProvider pro = new DataProvider();
        try
        {
          String query = "SELECT * FROM loaisanpham";
          pro.open();
          ResultSet rs = pro.excutequery(query);
          while(rs.next())
          {
              LOAISANPHAMDTO dao = new LOAISANPHAMDTO();
              dao.setMaloaisp(Integer.parseInt(rs.getString("maloaisp")));
              dao.setTenloai(rs.getString("tenloai"));
              ds.add(dao);
          }
        }
        catch(SQLException e)
        {
            e.printStackTrace();
        }
        finally{
            pro.close();
        }
        return ds;
    }
}
